package com.tudouji.project.mt.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.mt.domain.MtFoodconsum;
import com.tudouji.project.mt.service.IMtFoodconsumService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 美团菜品消耗单主Controller
 * 
 * @author tudouji
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/mt/foodconsum")
public class MtFoodconsumController extends BaseController
{
    @Autowired
    private IMtFoodconsumService mtFoodconsumService;

    /**
     * 查询美团菜品消耗单主列表
     */
    @PreAuthorize("@ss.hasPermi('mt:foodconsum:list')")
    @GetMapping("/list")
    public TableDataInfo list(MtFoodconsum mtFoodconsum)
    {
        startPage();
        List<MtFoodconsum> list = mtFoodconsumService.selectMtFoodconsumList(mtFoodconsum);
        return getDataTable(list);
    }

    /**
     * 导出美团菜品消耗单主列表
     */
    @PreAuthorize("@ss.hasPermi('mt:foodconsum:export')")
    @Log(title = "美团菜品消耗单主", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MtFoodconsum mtFoodconsum)
    {
        List<MtFoodconsum> list = mtFoodconsumService.selectMtFoodconsumList(mtFoodconsum);
        ExcelUtil<MtFoodconsum> util = new ExcelUtil<MtFoodconsum>(MtFoodconsum.class);
        return util.exportExcel(list, "foodconsum");
    }

    /**
     * 获取美团菜品消耗单主详细信息
     */
    @PreAuthorize("@ss.hasPermi('mt:foodconsum:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mtFoodconsumService.selectMtFoodconsumById(id));
    }

    /**
     * 新增美团菜品消耗单主
     */
    @PreAuthorize("@ss.hasPermi('mt:foodconsum:add')")
    @Log(title = "美团菜品消耗单主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MtFoodconsum mtFoodconsum)
    {
        return toAjax(mtFoodconsumService.insertMtFoodconsum(mtFoodconsum));
    }

    /**
     * 修改美团菜品消耗单主
     */
    @PreAuthorize("@ss.hasPermi('mt:foodconsum:edit')")
    @Log(title = "美团菜品消耗单主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MtFoodconsum mtFoodconsum)
    {
        return toAjax(mtFoodconsumService.updateMtFoodconsum(mtFoodconsum));
    }

    /**
     * 删除美团菜品消耗单主
     */
    @PreAuthorize("@ss.hasPermi('mt:foodconsum:remove')")
    @Log(title = "美团菜品消耗单主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mtFoodconsumService.deleteMtFoodconsumByIds(ids));
    }
}
